package com.dxx.cloud.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dxx.cloud.admin.mapper.GoodsTypeMapper;
import com.dxx.cloud.admin.module.entity.GoodsTypeEntity;
import com.dxx.cloud.admin.module.request.GoodsTypeListRequest;
import com.dxx.cloud.admin.service.IGoodsTypeService;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 * 商品类别 服务实现类
 * </p>
 *
 * @author dh
 * @since 2025-06-06
 */
@Service
public class GoodsTypeServiceImpl extends ServiceImpl<GoodsTypeMapper, GoodsTypeEntity> implements IGoodsTypeService {
    @Override
    public List topN(Integer top) {
        return getBaseMapper().topN(top);
    }

    @Override
    public List<GoodsTypeEntity> listByRequest(GoodsTypeListRequest request) {
        return list(new LambdaQueryWrapper<GoodsTypeEntity>().like(StringUtils.hasText(request.getName()), GoodsTypeEntity::getName, request.getName()).orderBy(true, true, GoodsTypeEntity::getOrderNo));
    }
}
